<?php


namespace Yond\LaravelDomain\Models;


use Illuminate\Database\Eloquent\Model as BaseModel;

abstract class Model extends BaseModel
{
    protected $tablePrefix;

    public function getTable(): string
    {
        return $this->table ?? is_null($this->tablePrefix) ? parent::getTable() : $this->tablePrefix . parent::getTable();
    }

    /**
     * Prepare a date for array / JSON serialization.
     *
     * @param \DateTimeInterface $date
     * @return string
     */
    protected function serializeDate(\DateTimeInterface $date): string
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }
}
